<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<html>
	<head>
		<meta http-equiv="Content-Language" content="zh-cn">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="${pageContext.request.contextPath}/css/Style1.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" language="javascript" src="${pageContext.request.contextPath}/js/jquery-3.2.1.js"></script>
		<script type="text/javascript">
			function showDetail(oid){
				if ($("#btn"+oid).val()=="订单详情") {
					// 1.创建异步加载对象
					var xhr = createXmlHttp();
					// 2.设置监听
					xhr.onreadystatechange=function(){
						if (xhr.readyState==4) {
							if (xhr.status==200) {
								$("#div"+oid).html(xhr.responseText);
							}
						}
					}
					// 3.打开链接
					xhr.open("GET","${pageContext.request.contextPath}/adminOrder_findOrderItem.action?time="+new Date()+"&oid="+oid,true);
					// 4.发送 
					xhr.send(null);
					$("#btn"+oid).val("关闭");
				}else{
					$("#btn"+oid).val("订单详情");
					$("#div"+oid).html("");
				}				
			}
			
			function createXmlHttp() {
				var xmlHttp;
				try { // Firefox, Opera 8.0+, Safari
					xmlHttp = new XMLHttpRequest();
				} catch (e) {
					try {// Internet Explorer
						xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try {
							xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
						} catch (e) {
						}
					}
				}

				return xmlHttp;
			}
		</script>
	</head>
	<body>
		<br>
		<form id="Form1" name="Form1" method="post">
			<table cellSpacing="1" cellPadding="0" width="100%" align="center" bgColor="#f5fafe" border="0">
				<tbody>
					<tr>
						<td class="ta_01" align="center" bgColor="#afd1f3">
							<strong>订 单 列 表</strong>
						</td>
					</tr>
					<tr>
						<td class="ta_01" align="center" bgColor="#f5fafe">
							<table cellspacing="0" cellpadding="1" rules="all"
								bordercolor="gray" border="1" id="DataGrid1"
								style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH: 100%; WORD-BREAK: break-all; BORDER-BOTTOM: gray 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #f5fafe; WORD-WRAP: break-word">
								<tr style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3">
									<td align="center" width="18%">
										序号
									</td>
									<td align="center" width="17%">
										订单编号
									</td>
									<td align="center" width="17%">
										总金额
									</td>
									<td align="center" width="17%">
										收货人
									</td>
									<td align="center" width="17%">
										订单状态
									</td>
									<td align="center" width="7%">
										订单详情
									</td>
								</tr>
								<s:iterator var="order" value="pageBean.list" status="status">
										<tr onmouseover="this.style.backgroundColor = 'white'"
											onmouseout="this.style.backgroundColor = '#F5FAFE';">
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="18%">
												<s:property value="#status.count"/>
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%">
												<s:property value="#order.oid"/>
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%">
												<s:property value="#order.total"/>
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%">
												<s:property value="#order.name"/>
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%">
												<s:if test="#order.state==1">
													未付款
												</s:if>
												<s:if test="#order.state==2">
													<a href="${ pageContext.request.contextPath }/adminOrder_updateState.action?oid=<s:property value="#order.oid"/>"><font color="blue">发货</font></a>
												</s:if>
												<s:if test="#order.state==3">
													未确认收货
												</s:if>
												<s:if test="#order.state==4">
													交易完成
												</s:if>
											</td>
											<td align="center" style="HEIGHT: 22px">
												<input id="btn<s:property value="#order.oid"/>" type="button" value="订单详情" onclick="showDetail(<s:property value="#order.oid"/>)"/>
												<div id="div<s:property value="#order.oid"/>"></div>
											</td>
										</tr>
									</s:iterator>	
							</table>
						</td>
					</tr>
					
					<tr align="center">
						<td class="ta_01" align="center" bgColor="#afd1f3">
							第<s:property value="pageBean.page" />/<s:property value="pageBean.totalPage" />页&nbsp;&nbsp;&nbsp;&nbsp;
							<s:if test="pageBean.page!=1">
								<a href="${pageContext.request.contextPath}/adminOrder_findAllByPage.action?page=1">首页</a>
								<a href="${pageContext.request.contextPath}/adminOrder_findAllByPage.action?page=<s:property value="pageBean.page-1"/>">上一页</a>
							</s:if>
							<s:if test="pageBean.page!=pageBean.totalPage">
								<a href="${pageContext.request.contextPath}/adminOrder_findAllByPage.action?page=<s:property value="pageBean.page+1"/>">下一页</a>
								<a href="${pageContext.request.contextPath}/adminOrder_findAllByPage.action?page=<s:property value="pageBean.totalPage"/>">尾页</a>
							</s:if>							
						</td>
					</tr>
					
				</tbody>
			</table>
		</form>
	</body>
</html>